package com.equipment.management.controller;


import com.equipment.management.entity.User;
import com.equipment.management.service.UserService;
import com.equipment.management.util.Base64Util;
import com.equipment.management.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping(value = "/login")
public class LoginController extends Base64Util {

    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public Result login(@RequestBody User user) throws Exception {
        log.info("登录参数：{}",user);
        User us = userService.getUserByMessage(user.getName(), user.getPassword());
        return us!=null?new Result(200,"登录成功",user):new Result(500,"登录失败",user);

    }
}
